﻿using Autofac;
using IOC.Interfaces;
using Microsoft.AspNetCore.Mvc;

namespace _54_Autofac_Progject.Controllers
{
    public class AutofacController : Controller
    {
        private readonly IMicroPhone microPhone;
        private readonly IPhone iphone;
        private readonly IEnumerable<IMicroPhone> list;

        // 属性注入
        private IMicroPhone IMicroPhoneProp { get; set; }

        public AutofacController(IMicroPhone microPhone, IPhone iphone, IEnumerable<IMicroPhone> list,IServiceProvider serviceProvider,IComponentContext componentContext)
        {
            this.microPhone = microPhone;
            this.iphone = iphone;
            this.list = list;

            IMicroPhone microPhone1 =serviceProvider.GetService<IMicroPhone>();

            IMicroPhone microPhone2 = componentContext.Resolve<IMicroPhone>();

        }
        public IActionResult Index()
        {
            return Ok("成功");
        }
    }
}
